package com.ruoyi.common.mapper;

import com.ruoyi.common.CommonProvider;
import com.ruoyi.common.domain.po.BasePO;
import com.ruoyi.common.domain.qo.BaseQO;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BaseMapper<P extends BasePO, Q extends BaseQO<P>> {
    @SelectProvider(type = CommonProvider.class, method = "select")
    List<P> select(Q q);

    @InsertProvider(type = CommonProvider.class, method = "insert")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insert(P p);

    @InsertProvider(type = CommonProvider.class, method = "batchInsert")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int batchInsert(@Param("ps") List<P> ps);

    @UpdateProvider(type = CommonProvider.class, method = "update")
    int update(Q q);

    @UpdateProvider(type = CommonProvider.class, method = "updateSelective")
    int updateSelective(Q q);
    @DeleteProvider(type = CommonProvider.class, method = "delete")
    int delete(Q q);
}
